package com.domcer.ultra.menu.domain;

import com.domcer.ultra.menu.common.utils.InventoryUtil;
import lombok.*;
import org.bukkit.configuration.ConfigurationSection;

import java.util.List;

/**
 * @Author hang.wang
 * @Date 2025/1/30 22:53
 */
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MenuItemDomain {
    private String material;
    private int x;
    private int y;
    private int slot;
    private List<String> name;
    private List<String> clickActions;
    private List<String> showRequires;

    public static MenuItemDomain assemble(ConfigurationSection section) {
        if (section == null) {
            return null;
        }

        return MenuItemDomain.builder()
                .material(section.getString("material", "bedrock"))
                .x(section.getInt("x", 0))
                .y(section.getInt("y", 0))
                .slot(InventoryUtil.slot(section.getInt("x", 0), section.getInt("y", 0)))
                .name(section.getStringList("name"))
                .clickActions(section.getStringList("click-actions"))
                .showRequires(section.getStringList("show-requires"))
                .build();
    }
}
